import moment from 'moment';

let dates = [];
let data = [];

const range = [60, 100];

for (let i = 0; i <= 7 * 24; i++) {
    const value = (Math.random() * (range[1] - range[0]) + range[0]).toFixed(2);
    dates.push(moment().subtract(7 * 24 - i, 'hour').format('YYYY-MM-DD HH:mm:SS'));
    data.push(value);
}

export const storageOption = {
    color: ['#348EED', '#FBDF90'],
    grid: {
        top: '15%',
        left: 60,
        right: 60,
        height: '65%'
    },
    title: {
        text: '硬盘使用率'
    },
    tooltip: {
        trigger: 'axis'
    },
    toolbox: {
        feature: {
            saveAsImage: { name: 'DHCP', title: '保存' }
        }
    },
    xAxis: {
        data: dates
    },
    yAxis: {
        type: 'value'
    },
    visualMap: {
        show: false,
        pieces: [{
            gt: 0,
            lte: 50,
            color: '#2d8cf0'
        }, {
            gt: 50,
            lte: 85,
            color: '#ff9900'
        }, {
            gt: 85,
            lte: 100,
            color: '#ed3f14'
        }]
    },
    dataZoom: [
        {
            show: true,
            realtime: true,
            start: 0,
            end: 100
        }
    ],
    series: [
        {
            data,
            type: 'line'
        }
    ],
    animationDuration: 1000
};
